package pe.com.rix.taglib.view;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.JspFragment;
import javax.servlet.jsp.tagext.SimpleTagSupport;

import pe.com.rix.taglib.bean.menu.MenuItem;


public class MenuSimple extends SimpleTagSupport{

	private MenuItem menuRoot;
	
	@Override
	public void doTag() throws JspException {
	
		StringBuffer html = new StringBuffer("<ul id='menuToolbar' style='display:none'>");
		
		MenuItem.doHtml(getMenuRoot().getItems(), html);

		html.append("</ul>");
		
		
		JspWriter out = getJspContext().getOut();
		try {
			JspFragment f = getJspBody();
			if (f != null) {
				f.invoke(out);
			}
			out.print(html.toString());
		} catch (java.io.IOException ex) {
			throw new JspException(ex.getMessage());
		}
	}
	
	
	
	
	
	public MenuItem getMenuRoot() {
		return menuRoot;
	}
	
	public void setMenuRoot(MenuItem menuRoot) {
		this.menuRoot = menuRoot;
	}
	
}
